<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .active{
            text-decoration: underline;
        }
        .disabled{
            cursor: not-allowed;
        }
    </style>
</head>
<body>
    <div id="app">
        <div>当前是第{{currentPage}}页</div>
        <button 
         v-bind:disabled="currentPage==1"
         v-on:click="changePage('-')"
         :class="{disabled:currentPage==1}"
         >上一页</button>
        <button 
            v-for="num in 5" 
            v-on:click="changePage(num)"
            v-bind:class="{active:num == currentPage}">
            {{num}}          
        </button>
        <button
          :disabled='currentPage==5'
          v-on:click="changePage('+')"
          :class="{disabled:currentPage==5}"
          >下一页</button>
    </div>
    <script src="./vue.js"></script>
    <script>
        let vm = new Vue({
            el: '#app',
            data:{
                currentPage:1
            },
            methods:{
                changePage(flag){
                    if(flag==='+'&&this.currentPage<5){
                        this.currentPage++;
                    }else if(flag==='-'&&this.currentPage>1){
                        this.currentPage--;
                    }else if(flag>0){
                        this.currentPage = flag;
                    }
                    
                },
            },
        });
    </script>
</body>
</html>